import configparser
import json
import logging
import os
import queue
import random
import sys
from typing import List

from PyQt5.QtCore import QThread, pyqtSignal, QTimer
from PyQt5.QtWidgets import QMessageBox, QApplication
from paho.mqtt import client as mqtt_client

from data.defines import *

file_path_mac = os.getcwd() + '/'
file_path_win = os.getcwd() + '\\'


# "数据链遥控链路异常"
# "数据链遥测链路异常"
# "数据链图像异常"
# "大气机气压高度异常"
# "大气机空速异常"
# "大气机垂直速度异常"
# "VHF工作异常"
# "发动机转速异常"
# "发动机油门开度异常"
# "滑油温度异常"
# "滑油压力异常"
# "燃油消耗率波动异常"
# "燃油压力异常"
# "燃油量告警"
# "空气箱温度异常"
# "发电机温度异常"
# "气缸温度异常"
# "排气温度异常"
# "雷达高度异常"
# "指令发送失败"
# "高度信号源故障"
# "导航信号源故障"
# "姿态信号源故障"
# "升降舵机故障"
# "方向舵机故障"
# "左/右副翼舵机故障"
# "襟翼舵机故障"
# "油门舵机故障"
# "前轮转向舵机故障"
# "左/右刹车压力故障"
# "结冰探测器故障"
# "空速管加温故障"
# "货舱火警"
# "发动机火警"
# "货舱/发动机火情探测器故障"
# "UPS稳压电源异常"
# "发动机模式错误"
# "横向模式错误"
# "纵向模式错误"
# "惯导状态错误"
# "14V电流异常"
# "14V电压异常"
# "汇流条A电流异常"
# "汇流条A电压异常"
# "汇流条B电流异常"
# "汇流条B电压异常"
# "蓄电池电流异常"
# "蓄电池电压异常"
# "发电机A电流异常"
# "发电机B电流异常"
# "进气歧管压力异常"
# "RTK定位故障"

class WarnParamInfo:
    INVALID = 0  # 无告警信息，显示白色
    NORMAL = 0  # 正常情况，显示白色
    WARN = 1  # 异常情况，普通告警，显示黄色
    CRITICAL = 2  # 紧急情况，显示红色
    cur_warn_level = INVALID
    cur_val = 0
    counter = 0

    def __init__(self):
        self.inited = False
        self.limit1 = 0.0
        self.limit2 = 0.0
        self.limit3 = 0.0
        self.limit4 = 0.0

    def warn_level(self, cur_val: float):
        cur_warn_level = self.NORMAL
        if self.inited is True:
            if cur_val <= self.limit1 or cur_val >= self.limit4:
                cur_warn_level = self.CRITICAL
            if self.limit1 < cur_val <= self.limit2:
                cur_warn_level = self.WARN
            if self.limit3 <= cur_val < self.limit4:
                cur_warn_level = self.WARN
            if self.limit2 <= cur_val <= self.limit3:
                cur_warn_level = self.NORMAL
        self.cur_warn_level = cur_warn_level
        self.cur_val = cur_val
        return cur_warn_level

    def checkConfig(self):
        if self.limit1 <= self.limit2 < self.limit3 <= self.limit4:
            self.inited = True
        else:
            self.inited = False


class WarnningHandler(QThread):
    Eng_rpm = WarnParamInfo()
    Eng_AirPress = WarnParamInfo()
    Eng_AirTmp = WarnParamInfo()
    Eng_PressCmd = WarnParamInfo()
    Eng_CorTmp = WarnParamInfo()
    Eng_CorPress = WarnParamInfo()
    Eng_Cyl2Tmp = WarnParamInfo()
    Eng_Cyl3Tmp = WarnParamInfo()
    Eng_LubeTmp = WarnParamInfo()
    Eng_LubePress = WarnParamInfo()
    Eng_Gene1 = WarnParamInfo()
    Eng_Gene2 = WarnParamInfo()
    Cur_Bat = WarnParamInfo()
    Vol_A = WarnParamInfo()
    Cur_A = WarnParamInfo()
    Vol_B = WarnParamInfo()
    Cur_B = WarnParamInfo()
    Vol_C = WarnParamInfo()
    Cur_C = WarnParamInfo()
    fuel_Left = WarnParamInfo()
    Fuel_right = WarnParamInfo()
    Press_Fuel = WarnParamInfo()
    Press_Air = WarnParamInfo()
    Temp_Gas1 = WarnParamInfo()
    Temp_Gas2 = WarnParamInfo()
    Rudder_Stuck = WarnParamInfo()

    Temp_Gas3 = WarnParamInfo()
    Temp_Gas4 = WarnParamInfo()
    Eng_Thr = WarnParamInfo()
    Eng_Servo = WarnParamInfo()
    Phi_Track_Bias = WarnParamInfo()
    Theta_Track_Bias = WarnParamInfo()
    ELEL_Actuator_Bias = WarnParamInfo()
    ELER_Actuator_Bias = WarnParamInfo()
    AILL_Actuator_Bias = WarnParamInfo()
    AILR_Actuator_Bias = WarnParamInfo()
    RUD_Actuator_Bias = WarnParamInfo()
    FLAP_Actuator_Bias = WarnParamInfo()
    Brake_Press = WarnParamInfo()
    Gear_Actuator_Bias = WarnParamInfo()
    Ulink_Freq = WarnParamInfo()
    Llink_Freq = WarnParamInfo()
    Glink_Freq = WarnParamInfo()
    Downlload_Freq = WarnParamInfo()

    def __init__(self):
        super().__init__()

        self.send_timer = QTimer()
        self.send_timer.timeout.connect(self.timer_process)
        self.send_timer.setInterval(500)
        self._warn_config_init()
        # print("_warn_config_init called")
        self.start()

    def _warn_config_init(self):
        current = os.getcwd()
        if current.startswith('/'):
            filename = file_path_mac + warning_filename
        else:
            filename = file_path_win + warning_filename
        if os.path.exists(filename):
            cf = configparser.ConfigParser()
            try:
                cf.read(filename)
                self.Eng_rpm.limit1 = cf.getfloat("Eng_rpm", "limit1", fallback=0.0)
                self.Eng_rpm.limit2 = cf.getfloat("Eng_rpm", "limit2", fallback=0.0)
                self.Eng_rpm.limit3 = cf.getfloat("Eng_rpm", "limit3", fallback=0.0)
                self.Eng_rpm.limit4 = cf.getfloat("Eng_rpm", "limit4", fallback=0.0)

                self.Eng_AirPress.limit1 = cf.getfloat("Eng_AirPress", "limit1", fallback=0.0)
                self.Eng_AirPress.limit2 = cf.getfloat("Eng_AirPress", "limit2", fallback=0.0)
                self.Eng_AirPress.limit3 = cf.getfloat("Eng_AirPress", "limit3", fallback=0.0)
                self.Eng_AirPress.limit4 = cf.getfloat("Eng_AirPress", "limit4", fallback=0.0)

                self.Eng_AirTmp.limit1 = cf.getfloat("Eng_AirTmp", "limit1", fallback=0.0)
                self.Eng_AirTmp.limit2 = cf.getfloat("Eng_AirTmp", "limit2", fallback=0.0)
                self.Eng_AirTmp.limit3 = cf.getfloat("Eng_AirTmp", "limit3", fallback=0.0)
                self.Eng_AirTmp.limit4 = cf.getfloat("Eng_AirTmp", "limit4", fallback=0.0)

                self.Eng_PressCmd.limit1 = cf.getfloat("Eng_PressCmd", "limit1", fallback=0.0)
                self.Eng_PressCmd.limit2 = cf.getfloat("Eng_PressCmd", "limit2", fallback=0.0)
                self.Eng_PressCmd.limit3 = cf.getfloat("Eng_PressCmd", "limit3", fallback=0.0)
                self.Eng_PressCmd.limit4 = cf.getfloat("Eng_PressCmd", "limit4", fallback=0.0)

                self.Eng_CorTmp.limit1 = cf.getfloat("Eng_CorTmp", "limit1", fallback=0.0)
                self.Eng_CorTmp.limit2 = cf.getfloat("Eng_CorTmp", "limit2", fallback=0.0)
                self.Eng_CorTmp.limit3 = cf.getfloat("Eng_CorTmp", "limit3", fallback=0.0)
                self.Eng_CorTmp.limit4 = cf.getfloat("Eng_CorTmp", "limit4", fallback=0.0)

                self.Eng_CorPress.limit1 = cf.getfloat("Eng_CorPress", "limit1", fallback=0.0)
                self.Eng_CorPress.limit2 = cf.getfloat("Eng_CorPress", "limit2", fallback=0.0)
                self.Eng_CorPress.limit3 = cf.getfloat("Eng_CorPress", "limit3", fallback=0.0)
                self.Eng_CorPress.limit4 = cf.getfloat("Eng_CorPress", "limit4", fallback=0.0)

                self.Eng_Cyl2Tmp.limit1 = cf.getfloat("Eng_Cyl2Tmp", "limit1", fallback=0.0)
                self.Eng_Cyl2Tmp.limit2 = cf.getfloat("Eng_Cyl2Tmp", "limit2", fallback=0.0)
                self.Eng_Cyl2Tmp.limit3 = cf.getfloat("Eng_Cyl2Tmp", "limit3", fallback=0.0)
                self.Eng_Cyl2Tmp.limit4 = cf.getfloat("Eng_Cyl2Tmp", "limit4", fallback=0.0)

                self.Eng_Cyl3Tmp.limit1 = cf.getfloat("Eng_Cyl3Tmp", "limit1", fallback=0.0)
                self.Eng_Cyl3Tmp.limit2 = cf.getfloat("Eng_Cyl3Tmp", "limit2", fallback=0.0)
                self.Eng_Cyl3Tmp.limit3 = cf.getfloat("Eng_Cyl3Tmp", "limit3", fallback=0.0)
                self.Eng_Cyl3Tmp.limit4 = cf.getfloat("Eng_Cyl3Tmp", "limit4", fallback=0.0)

                self.Eng_LubeTmp.limit1 = cf.getfloat("Eng_LubeTmp", "limit1", fallback=0.0)
                self.Eng_LubeTmp.limit2 = cf.getfloat("Eng_LubeTmp", "limit2", fallback=0.0)
                self.Eng_LubeTmp.limit3 = cf.getfloat("Eng_LubeTmp", "limit3", fallback=0.0)
                self.Eng_LubeTmp.limit4 = cf.getfloat("Eng_LubeTmp", "limit4", fallback=0.0)

                self.Eng_LubePress.limit1 = cf.getfloat("Eng_LubePress", "limit1", fallback=0.0)
                self.Eng_LubePress.limit2 = cf.getfloat("Eng_LubePress", "limit2", fallback=0.0)
                self.Eng_LubePress.limit3 = cf.getfloat("Eng_LubePress", "limit3", fallback=0.0)
                self.Eng_LubePress.limit4 = cf.getfloat("Eng_LubePress", "limit4", fallback=0.0)

                self.Eng_Gene1.limit1 = cf.getfloat("Eng_Gene1", "limit1", fallback=0.0)
                self.Eng_Gene1.limit2 = cf.getfloat("Eng_Gene1", "limit2", fallback=0.0)
                self.Eng_Gene1.limit3 = cf.getfloat("Eng_Gene1", "limit3", fallback=0.0)
                self.Eng_Gene1.limit4 = cf.getfloat("Eng_Gene1", "limit4", fallback=0.0)

                self.Eng_Gene2.limit1 = cf.getfloat("Eng_Gene2", "limit1", fallback=0.0)
                self.Eng_Gene2.limit2 = cf.getfloat("Eng_Gene2", "limit2", fallback=0.0)
                self.Eng_Gene2.limit3 = cf.getfloat("Eng_Gene2", "limit3", fallback=0.0)
                self.Eng_Gene2.limit4 = cf.getfloat("Eng_Gene2", "limit4", fallback=0.0)

                self.Cur_Bat.limit1 = cf.getfloat("Cur_Bat", "limit1", fallback=0.0)
                self.Cur_Bat.limit2 = cf.getfloat("Cur_Bat", "limit2", fallback=0.0)
                self.Cur_Bat.limit3 = cf.getfloat("Cur_Bat", "limit3", fallback=0.0)
                self.Cur_Bat.limit4 = cf.getfloat("Cur_Bat", "limit4", fallback=0.0)

                self.Vol_A.limit1 = cf.getfloat("Vol_A", "limit1", fallback=0.0)
                self.Vol_A.limit2 = cf.getfloat("Vol_A", "limit2", fallback=0.0)
                self.Vol_A.limit3 = cf.getfloat("Vol_A", "limit3", fallback=0.0)
                self.Vol_A.limit4 = cf.getfloat("Vol_A", "limit4", fallback=0.0)

                self.Cur_A.limit1 = cf.getfloat("Cur_A", "limit1", fallback=0.0)
                self.Cur_A.limit2 = cf.getfloat("Cur_A", "limit2", fallback=0.0)
                self.Cur_A.limit3 = cf.getfloat("Cur_A", "limit3", fallback=0.0)
                self.Cur_A.limit4 = cf.getfloat("Cur_A", "limit4", fallback=0.0)

                self.Vol_B.limit1 = cf.getfloat("Vol_B", "limit1", fallback=0.0)
                self.Vol_B.limit2 = cf.getfloat("Vol_B", "limit2", fallback=0.0)
                self.Vol_B.limit3 = cf.getfloat("Vol_B", "limit3", fallback=0.0)
                self.Vol_B.limit4 = cf.getfloat("Vol_B", "limit4", fallback=0.0)

                self.Cur_B.limit1 = cf.getfloat("Cur_B", "limit1", fallback=0.0)
                self.Cur_B.limit2 = cf.getfloat("Cur_B", "limit2", fallback=0.0)
                self.Cur_B.limit3 = cf.getfloat("Cur_B", "limit3", fallback=0.0)
                self.Cur_B.limit4 = cf.getfloat("Cur_B", "limit4", fallback=0.0)

                self.Vol_C.limit1 = cf.getfloat("Vol_C", "limit1", fallback=0.0)
                self.Vol_C.limit2 = cf.getfloat("Vol_C", "limit2", fallback=0.0)
                self.Vol_C.limit3 = cf.getfloat("Vol_C", "limit3", fallback=0.0)
                self.Vol_C.limit4 = cf.getfloat("Vol_C", "limit4", fallback=0.0)

                self.Cur_C.limit1 = cf.getfloat("Cur_C", "limit1", fallback=0.0)
                self.Cur_C.limit2 = cf.getfloat("Cur_C", "limit2", fallback=0.0)
                self.Cur_C.limit3 = cf.getfloat("Cur_C", "limit3", fallback=0.0)
                self.Cur_C.limit4 = cf.getfloat("Cur_C", "limit4", fallback=0.0)

                self.fuel_Left.limit1 = cf.getfloat("fuel_Left", "limit1", fallback=0.0)
                self.fuel_Left.limit2 = cf.getfloat("fuel_Left", "limit2", fallback=0.0)
                self.fuel_Left.limit3 = cf.getfloat("fuel_Left", "limit3", fallback=0.0)
                self.fuel_Left.limit4 = cf.getfloat("fuel_Left", "limit4", fallback=0.0)

                self.Fuel_right.limit1 = cf.getfloat("Fuel_right", "limit1", fallback=0.0)
                self.Fuel_right.limit2 = cf.getfloat("Fuel_right", "limit2", fallback=0.0)
                self.Fuel_right.limit3 = cf.getfloat("Fuel_right", "limit3", fallback=0.0)
                self.Fuel_right.limit4 = cf.getfloat("Fuel_right", "limit4", fallback=0.0)

                self.Press_Fuel.limit1 = cf.getfloat("Press_Fuel", "limit1", fallback=0.0)
                self.Press_Fuel.limit2 = cf.getfloat("Press_Fuel", "limit2", fallback=0.0)
                self.Press_Fuel.limit3 = cf.getfloat("Press_Fuel", "limit3", fallback=0.0)
                self.Press_Fuel.limit4 = cf.getfloat("Press_Fuel", "limit4", fallback=0.0)

                self.Press_Air.limit1 = cf.getfloat("Press_Air", "limit1", fallback=0.0)
                self.Press_Air.limit2 = cf.getfloat("Press_Air", "limit2", fallback=0.0)
                self.Press_Air.limit3 = cf.getfloat("Press_Air", "limit3", fallback=0.0)
                self.Press_Air.limit4 = cf.getfloat("Press_Air", "limit4", fallback=0.0)

                self.Temp_Gas1.limit1 = cf.getfloat("Temp_Gas1", "limit1", fallback=0.0)
                self.Temp_Gas1.limit2 = cf.getfloat("Temp_Gas1", "limit2", fallback=0.0)
                self.Temp_Gas1.limit3 = cf.getfloat("Temp_Gas1", "limit3", fallback=0.0)
                self.Temp_Gas1.limit4 = cf.getfloat("Temp_Gas1", "limit4", fallback=0.0)

                self.Temp_Gas2.limit1 = cf.getfloat("Temp_Gas2", "limit1", fallback=0.0)
                self.Temp_Gas2.limit2 = cf.getfloat("Temp_Gas2", "limit2", fallback=0.0)
                self.Temp_Gas2.limit3 = cf.getfloat("Temp_Gas2", "limit3", fallback=0.0)
                self.Temp_Gas2.limit4 = cf.getfloat("Temp_Gas2", "limit4", fallback=0.0)

                self.Rudder_Stuck.limit1 = cf.getfloat("Rudder_Stuck", "limit1", fallback=0.0)
                self.Rudder_Stuck.limit2 = cf.getfloat("Rudder_Stuck", "limit2", fallback=0.0)
                self.Rudder_Stuck.limit3 = cf.getfloat("Rudder_Stuck", "limit3", fallback=0.0)
                self.Rudder_Stuck.limit4 = cf.getfloat("Rudder_Stuck", "limit4", fallback=0.0)

                self.Temp_Gas3.limit1 = cf.getfloat("Temp_Gas3", "limit1", fallback=0.0)
                self.Temp_Gas3.limit2 = cf.getfloat("Temp_Gas3", "limit2", fallback=0.0)
                self.Temp_Gas3.limit3 = cf.getfloat("Temp_Gas3", "limit3", fallback=0.0)
                self.Temp_Gas3.limit4 = cf.getfloat("Temp_Gas3", "limit4", fallback=0.0)

                self.Temp_Gas4.limit1 = cf.getfloat("Temp_Gas4", "limit1", fallback=0.0)
                self.Temp_Gas4.limit2 = cf.getfloat("Temp_Gas4", "limit2", fallback=0.0)
                self.Temp_Gas4.limit3 = cf.getfloat("Temp_Gas4", "limit3", fallback=0.0)
                self.Temp_Gas4.limit4 = cf.getfloat("Temp_Gas4", "limit4", fallback=0.0)

                self.Eng_Thr.limit1 = cf.getfloat("Eng_Thr", "limit1", fallback=0.0)
                self.Eng_Thr.limit2 = cf.getfloat("Eng_Thr", "limit2", fallback=0.0)
                self.Eng_Thr.limit3 = cf.getfloat("Eng_Thr", "limit3", fallback=0.0)
                self.Eng_Thr.limit4 = cf.getfloat("Eng_Thr", "limit4", fallback=0.0)

                self.Phi_Track_Bias.limit1 = cf.getfloat("Phi_Track_Bias", "limit1", fallback=0.0)
                self.Phi_Track_Bias.limit2 = cf.getfloat("Phi_Track_Bias", "limit2", fallback=0.0)
                self.Phi_Track_Bias.limit3 = cf.getfloat("Phi_Track_Bias", "limit3", fallback=0.0)
                self.Phi_Track_Bias.limit4 = cf.getfloat("Phi_Track_Bias", "limit4", fallback=0.0)

                self.Theta_Track_Bias.limit1 = cf.getfloat("Theta_Track_Bias", "limit1", fallback=0.0)
                self.Theta_Track_Bias.limit2 = cf.getfloat("Theta_Track_Bias", "limit2", fallback=0.0)
                self.Theta_Track_Bias.limit3 = cf.getfloat("Theta_Track_Bias", "limit3", fallback=0.0)
                self.Theta_Track_Bias.limit4 = cf.getfloat("Theta_Track_Bias", "limit4", fallback=0.0)

                self.ELEL_Actuator_Bias.limit1 = cf.getfloat("ELEL_Actuator_Bias", "limit1", fallback=0.0)
                self.ELEL_Actuator_Bias.limit2 = cf.getfloat("ELEL_Actuator_Bias", "limit2", fallback=0.0)
                self.ELEL_Actuator_Bias.limit3 = cf.getfloat("ELEL_Actuator_Bias", "limit3", fallback=0.0)
                self.ELEL_Actuator_Bias.limit4 = cf.getfloat("ELEL_Actuator_Bias", "limit4", fallback=0.0)

                self.ELER_Actuator_Bias.limit1 = cf.getfloat("ELER_Actuator_Bias", "limit1", fallback=0.0)
                self.ELER_Actuator_Bias.limit2 = cf.getfloat("ELER_Actuator_Bias", "limit2", fallback=0.0)
                self.ELER_Actuator_Bias.limit3 = cf.getfloat("ELER_Actuator_Bias", "limit3", fallback=0.0)
                self.ELER_Actuator_Bias.limit4 = cf.getfloat("ELER_Actuator_Bias", "limit4", fallback=0.0)

                self.AILL_Actuator_Bias.limit1 = cf.getfloat("AILL_Actuator_Bias", "limit1", fallback=0.0)
                self.AILL_Actuator_Bias.limit2 = cf.getfloat("AILL_Actuator_Bias", "limit2", fallback=0.0)
                self.AILL_Actuator_Bias.limit3 = cf.getfloat("AILL_Actuator_Bias", "limit3", fallback=0.0)
                self.AILL_Actuator_Bias.limit4 = cf.getfloat("AILL_Actuator_Bias", "limit4", fallback=0.0)

                self.AILR_Actuator_Bias.limit1 = cf.getfloat("AILR_Actuator_Bias", "limit1", fallback=0.0)
                self.AILR_Actuator_Bias.limit2 = cf.getfloat("AILR_Actuator_Bias", "limit2", fallback=0.0)
                self.AILR_Actuator_Bias.limit3 = cf.getfloat("AILR_Actuator_Bias", "limit3", fallback=0.0)
                self.AILR_Actuator_Bias.limit4 = cf.getfloat("AILR_Actuator_Bias", "limit4", fallback=0.0)

                self.RUD_Actuator_Bias.limit1 = cf.getfloat("RUD_Actuator_Bias", "limit1", fallback=0.0)
                self.RUD_Actuator_Bias.limit2 = cf.getfloat("RUD_Actuator_Bias", "limit2", fallback=0.0)
                self.RUD_Actuator_Bias.limit3 = cf.getfloat("RUD_Actuator_Bias", "limit3", fallback=0.0)
                self.RUD_Actuator_Bias.limit4 = cf.getfloat("RUD_Actuator_Bias", "limit4", fallback=0.0)

                self.FLAP_Actuator_Bias.limit1 = cf.getfloat("FLAP_Actuator_Bias", "limit1", fallback=0.0)
                self.FLAP_Actuator_Bias.limit2 = cf.getfloat("FLAP_Actuator_Bias", "limit2", fallback=0.0)
                self.FLAP_Actuator_Bias.limit3 = cf.getfloat("FLAP_Actuator_Bias", "limit3", fallback=0.0)
                self.FLAP_Actuator_Bias.limit4 = cf.getfloat("FLAP_Actuator_Bias", "limit4", fallback=0.0)

                self.Brake_Press.limit1 = cf.getfloat("Brake_Press", "limit1", fallback=0.0)
                self.Brake_Press.limit2 = cf.getfloat("Brake_Press", "limit2", fallback=0.0)
                self.Brake_Press.limit3 = cf.getfloat("Brake_Press", "limit3", fallback=0.0)
                self.Brake_Press.limit4 = cf.getfloat("Brake_Press", "limit4", fallback=0.0)

                self.Gear_Actuator_Bias.limit1 = cf.getfloat("Gear_Actuator_Bias", "limit1", fallback=0.0)
                self.Gear_Actuator_Bias.limit2 = cf.getfloat("Gear_Actuator_Bias", "limit2", fallback=0.0)
                self.Gear_Actuator_Bias.limit3 = cf.getfloat("Gear_Actuator_Bias", "limit3", fallback=0.0)
                self.Gear_Actuator_Bias.limit4 = cf.getfloat("Gear_Actuator_Bias", "limit4", fallback=0.0)

                self.Ulink_Freq.limit1 = cf.getfloat("Ulink_Freq", "limit1", fallback=0.0)
                self.Ulink_Freq.limit2 = cf.getfloat("Ulink_Freq", "limit2", fallback=0.0)
                self.Ulink_Freq.limit3 = cf.getfloat("Ulink_Freq", "limit3", fallback=0.0)
                self.Ulink_Freq.limit4 = cf.getfloat("Ulink_Freq", "limit4", fallback=0.0)

                self.Llink_Freq.limit1 = cf.getfloat("Llink_Freq", "limit1", fallback=0.0)
                self.Llink_Freq.limit2 = cf.getfloat("Llink_Freq", "limit2", fallback=0.0)
                self.Llink_Freq.limit3 = cf.getfloat("Llink_Freq", "limit3", fallback=0.0)
                self.Llink_Freq.limit4 = cf.getfloat("Llink_Freq", "limit4", fallback=0.0)

                self.Glink_Freq.limit1 = cf.getfloat("Glink_Freq", "limit1", fallback=0.0)
                self.Glink_Freq.limit2 = cf.getfloat("Glink_Freq", "limit2", fallback=0.0)
                self.Glink_Freq.limit3 = cf.getfloat("Glink_Freq", "limit3", fallback=0.0)
                self.Glink_Freq.limit4 = cf.getfloat("Glink_Freq", "limit4", fallback=0.0)

                self.Downlload_Freq.limit1 = cf.getfloat("Downlload_Freq", "limit1", fallback=0.0)
                self.Downlload_Freq.limit2 = cf.getfloat("Downlload_Freq", "limit2", fallback=0.0)
                self.Downlload_Freq.limit3 = cf.getfloat("Downlload_Freq", "limit3", fallback=0.0)
                self.Downlload_Freq.limit4 = cf.getfloat("Downlload_Freq", "limit4", fallback=0.0)
                logging.info("告警信息配置读取完成")

                self.Eng_rpm.checkConfig()
                self.Eng_AirPress.checkConfig()
                self.Eng_AirTmp.checkConfig()
                self.Eng_PressCmd.checkConfig()
                self.Eng_CorTmp.checkConfig()
                self.Eng_CorPress.checkConfig()
                self.Eng_Cyl2Tmp.checkConfig()
                self.Eng_Cyl3Tmp.checkConfig()
                self.Eng_LubeTmp.checkConfig()
                self.Eng_LubePress.checkConfig()
                self.Eng_Gene1.checkConfig()
                self.Eng_Gene2.checkConfig()
                self.Cur_Bat.checkConfig()
                self.Vol_A.checkConfig()
                self.Cur_A.checkConfig()
                self.Vol_B.checkConfig()
                self.Cur_B.checkConfig()
                self.Vol_C.checkConfig()
                self.Cur_C.checkConfig()
                self.fuel_Left.checkConfig()
                self.Fuel_right.checkConfig()
                self.Press_Fuel.checkConfig()
                self.Press_Air.checkConfig()
                self.Temp_Gas1.checkConfig()
                self.Temp_Gas2.checkConfig()
                self.Rudder_Stuck.checkConfig()

                self.Temp_Gas3.checkConfig()
                self.Temp_Gas4.checkConfig()
                self.Eng_Thr.checkConfig()
                self.Phi_Track_Bias.checkConfig()
                self.Theta_Track_Bias.checkConfig()
                self.ELEL_Actuator_Bias.checkConfig()
                self.ELER_Actuator_Bias.checkConfig()
                self.AILL_Actuator_Bias.checkConfig()
                self.AILR_Actuator_Bias.checkConfig()
                self.RUD_Actuator_Bias.checkConfig()
                self.FLAP_Actuator_Bias.checkConfig()
                self.Brake_Press.checkConfig()
                self.Gear_Actuator_Bias.checkConfig()
                self.Ulink_Freq.checkConfig()
                self.Llink_Freq.checkConfig()
                self.Glink_Freq.checkConfig()
                self.Downlload_Freq.checkConfig()

                logging.info("告警信息检查完成")
            except BaseException as e:
                logging.error(repr(e))
                logging.error("读取配置文件失败！")

    def timer_init(self):
        """
        初始化定时器
        """
        self.send_timer.start()

    def timer_process(self):
        print("告警信息检测")


warnhandler = WarnningHandler()
